//这个文件写的都是函数，我们叫接口请求函数
import request from './ajax'
import mockRequest from '@/api/mockAjax.js'

//请求三级分类列表数据
///api/product/getBaseCategoryList

//axios使用  函数用法  对象用法
export const reqCategoryList=()=>{
    return request({
        url:'/product/getBaseCategoryList',
        method: 'GET',
    })
};
//获取搜索商品列表的api
export const reqCommodity=(searchParams)=>{
    return request({
        url:'/list',
        method: 'post',
        data:searchParams,
    })
};
//获取商品详情的api
export const reqGoodsDetails=(skuId)=>{
    return request({
        url:`/item/${skuId}`,
        method: 'get',
    })
};
//添加购物车的api     /api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddCartSuccess=(skuId,skuNum) =>{
    return request({
        url:`/cart/addToCart/${skuId}/${skuNum}`,
        method: 'post',
    })
}
//获取购物车列表的api  /api/cart/cartList
export const reqShopCartList = () =>{
    return request({
        url:`/cart/cartList`,
        method:"get",
    })
}
//切换商品选中状态的   /api/cart/checkCart/{skuID}/{isChecked}
export const reqShopCarState= (skuID,isChecked) =>{
    return request({
        url:`/cart/checkCart/${skuID}/${isChecked}`,
        method: 'get',
    })
}
//删除购物车商品的API   /api/cart/deleteCart/{skuId}
export const reqDeleteCart =(skuId)=>{
    return request({
        url:`/cart/deleteCart/${skuId}`,
        method:'DELETE',
    });
}


//注册获取验证码的api    /api/user/passport/sendCode/phone
export const getSendCode = (phone)=>{
    return request({
        url: `/user/passport/sendCode/${phone}`,
        method:'get',
    })
};

//用户注册的api   /api/user/passport/register
export const reqUserRegister =(userInfo)=>{
    return request({
        url: `/user/passport/register`,
        method:'post',
        data:userInfo
    })
};
//用户登录的api    /api/user/passport/login
export const reqUserLogin =(userInfo)=>{
    return request({
        url:'/user/passport/login',
        method:'post',
        data:userInfo
    })
}





//mockAjax使用

export const reqBannerList=()=>{
    return mockRequest({
        url:'/banner',
        method: 'GET',
    })
};
export const reqFloorList=()=>{
    return mockRequest({
        url:'/floor',
        method: 'GET',
    })
};
